﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Data.SqlTypes;

public partial class FeedBack : System.Web.UI.Page
{
    AccessData ac = new AccessData();
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            if (Session["CustomerName"].ToString() == null || Session["CustomerName"].ToString() == "")
            {
                Response.Redirect("Error.aspx");
            }
            lblDate.Text = DateTime.Today.ToShortDateString();
            lblCustomerName.Text = Session["CustomerName"].ToString();
            int ProductID = int.Parse(Request.QueryString["ProductID"].ToString());
            SqlDataReader dr = ac.ExecuteReader("select ProductName from Products where ProductID = " + ProductID);
            if (dr.Read())
            {
                lblProductName.Text = dr[0].ToString();
            }

        }
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {

            int CustomerID = int.Parse(Session["CustomerID"].ToString());
            int ProductID = int.Parse(Request.QueryString["ProductID"].ToString());
            string conten = txtContent.Text;
            string sql = "insert into FeedBack values('" + conten + "'," + CustomerID + "," + ProductID + ",'" + DateTime.Now.ToString("yyyy-MM-dd") + "')";
            ac.ExeCuteQuery(sql);
            Response.Redirect("Default.aspx");

        }
        catch (Exception ex)
        {
            //Response.Write("Error :" + ex.Message);
            Response.Redirect("Error.aspx");
        }

    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
}
